/**
 * 行列的宽高设置
 */
function scColRowSizeSetting(opt){
    var com = scCommon.instance();
    var crEle = com.crEle;

    var box = null;
    var list = [
        {
            label: "宽度：", type: "component", component: "scNumber",
            param: {name: "width", minNum: 0.1, maxNum: 30, value: 1, step: 0.1, unit:"厘米"}
        },
        {
            label: "高度：", type: "component", component: "scNumber",
            param: {name: "height", minNum: 0.1, maxNum: 30, value: 1, step: 0.1, unit:"厘米"}
        }
    ];

    var listener = null;

    this.createView = function(option){
        option = option ? option : {};
        listener = option.listener;

        box = crEle("div", "sc-colrowsize-setting");
        com.insertNode(list, {}, box, "sc-colrowsize-setting-row", (node)=>{
            let commandName = "";
            let name = "";

            if(node.getName() == "width"){
                commandName = "setTableColumnWidth";
                name = "width";
            }else{
                commandName = "setTableRowHeight";
                name = "height";
            }

            node.addEventListener("change", (val)=>{
                let param = {};
                param[name] = val;
                listener["click"][0](commandName, param);
            });
        });

        return box;
    }

    /**
     * 通知
     * @param {*} eventType 
     * @param {*} param 
     */
    this.notify = function (eventType, param) {
        if(eventType == "mousedown"){
            if(param.cell){
                let attrs = param.cell.attributes;
                let nodes = box.querySelectorAll("[name]");
                for(let i = 0; i < nodes.length; i++){
                    nodes[i].value = attrs[nodes[i].name];
                }
            }
        }
    }
}